package com.kfm.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kfm.hotel.domain.SysDict;
import com.kfm.hotel.service.SysDictService;
import com.kfm.hotel.mapper.SysDictMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【sys_dict】的数据库操作Service实现
* @createDate 2023-06-18 13:30:47
*/
@Service
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict>
    implements SysDictService{
    @Override
    public PageInfo<SysDict> list(SysDict sysDict, Integer page, Integer limit) {
        //构建查询条件
        QueryWrapper<SysDict> wrapper = new QueryWrapper<>();
        wrapper.eq("is_del",0);
        //使用分页工具进行分页
        PageHelper.startPage(page,limit);
//数据库中查询
        List<SysDict> sysDicts = getBaseMapper().selectList(wrapper);
        //分装分页信息
        PageInfo<SysDict> info = new PageInfo<>(sysDicts);
        return info;
    }

    @Override
    public List<SysDict> getByType(int type) {
        QueryWrapper<SysDict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type",type);
        queryWrapper.eq("is_del",0);
        queryWrapper.orderByAsc("sort");
        return list(queryWrapper);
    }
}




